//
//  starImageManager.m
//  DLTravels
//
//  Created by mac1012 on 2016/12/15.
//  Copyright © 2016年 DianlE. All rights reserved.
//

#import "StarImageManager.h"



@implementation StarImageManager

+ (instancetype)shareStartImageManager{
    static StarImageManager *shared_Manager = nil;
    static dispatch_once_t one;
    dispatch_once(&one, ^{
        shared_Manager = [[self alloc] init];
    });
    return shared_Manager;
}

- (instancetype)init{
    
    if (self = [super init]) {
        
        [self createFolder:[self downloadPath]];
        
    }
    return self;
}

- (BOOL)createFolder:(NSString *)path{
    BOOL isDir = NO;
    NSFileManager *fileManager = [[NSFileManager alloc] init];
    BOOL existed = [fileManager fileExistsAtPath:path isDirectory:&isDir];
    BOOL isCreated = NO;
    if (!(isDir == YES && existed == YES)){
        isCreated = [fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    }else{
        isCreated = YES;
    }
    if (isCreated) {
        [NSURL addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:path isDirectory:YES]];
    }
    return isCreated;
}

- (NSString *)downloadPath{

    NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)firstObject];
    NSString *downloadPath = [documentPath stringByAppendingPathComponent:@"DLTravels_StartImages"];
    return downloadPath;
    
}

- (NSString *)pathOfSTPlist{
    return [[self downloadPath] stringByAppendingPathComponent:@"STARTIMAGE.plist"];
}

- (void)loadStartImages{
    NSArray *plistArray = [NSArray arrayWithContentsOfFile:[self pathOfSTPlist]];

}

/**
 获取随机图片

 */
- (StarImage *)randomImage{

    StarImage *startImage = [[StarImage alloc] init];
    
    return startImage;
    
    
//    if([NSDate isHolidays]){
//    
//    
//    }
}

@end

@implementation StarImage

- (void)startDownloadImage{


}

- (UIImage *)image{
    return [UIImage imageNamed:@"STARTIMAGE"];
}

@end


